//
//  ZoneViewController.m
//  09-省市区tableView
//
//  Created by dllo on 16/7/26.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "ZoneViewController.h"

@interface ZoneViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray<NSString *> *zoneArray;
@end

@implementation ZoneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor brownColor];
    NSLog(@"%@",_cityDic);
    NSString *cityName = _cityDic[@"市名"];
    NSArray *tempArr = [cityName componentsSeparatedByString:@" "];
    self.navigationItem.title = tempArr[2];
    self.tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
    _zoneArray = [NSMutableArray array];
    _zoneArray = _cityDic[@"区组"];
//    NSLog(@"%@",_zoneArray);
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _zoneArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuse];
    }
    NSString *cityName = _zoneArray[indexPath.row];
    NSArray *tempArr = [cityName componentsSeparatedByString:@" "];
    NSLog(@"%@",tempArr);
    cell.textLabel.text = tempArr[4];
    cell.detailTextLabel.text = [tempArr lastObject];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
